<?php
class Purview {
	public $db;
	function __construct() {
		$this->db = new Mysql ( );
	}
	function getMenus($username) {
	   $groupid = $this->getGroup($username);
	   $sql = "select pid,b.path,b.name,b.`order`,state,parentid from adm_group_purview a left join adm_purview b on  a.pid=b.id where a.gid='$groupid' order by `order`";
	   $menus['purview'] = $this->db->sql_fetch_rows($sql);
	   $sql = "select pid,subpurviewid,path,b.name from adm_user_baned_subpurview a left join adm_subpurview b on a.subpurviewid = b.id left join adm_user c on a.uid=c.id where c.username='$username' and b.name <> '' order by `order`";
	   $menus['subpurview'] = $this->db->sql_fetch_rows($sql);
	   return $menus;
	}
	function getGroup($username){
		$sql = "select `group` from adm_user a left join adm_group b on a.group = b.id where a.username='$username'";
		return $this->db->sql_fetch_one_cell($sql);
	}}
?>